<template>
  <div>
      <h3>son.vue-- {{ count }}</h3>
  </div>
</template>

<script>
export default {
    data() {
        return {
            count: 0,
            timer: null
        }
    },
    // 希望页面一打开就要有定时器
    created () {

       this.timer = setInterval(() => {
            console.log('定时器调用了')
            this.count++
        }, 1000);
    },

    beforeDestroy () {
        console.log('beforeDestroy')
    },


    destroyed() {
        clearInterval(this.timer)
        console.log('destroyed')
    }
}
</script>

<style>

</style>